<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Jedrzej\Pimpable\PimpableTrait;

class Integrallog extends Model
{
    use HasFactory;
    use PimpableTrait;

    //可批量赋值字段
    public $guarded = [];

    /**
     * 可搜索字段
     */
    public $searchable = [
        'id',
        'title',
        'created_at',
    ];

    /**
     *可以模糊查询的字段
     */
    public $searchableModels = [
        'title' => '%field%',
    ];

    //可排序字段
    public $sortable = [
        'id',
        'created_at'
    ];

    //title 类型
    public $titleEnum = [
        'sign'=> '签到奖励',
        'luck_draw' => '抽奖',
        'order' => '订单'
    ];


    //默认倒叙字段
    protected $defaultSortCriteria = ['id,desc'];

    //积分关联的用户的信息
    public function user()
    {
        return $this->belongsTo(User::class,'user_id','id');
    }
}
